import React from "react";

// 引入当前目录下面的所有文件
const ModulesFile = require.context('./',true,/.js$/);

const List = [];

// 不需要合并到总路由里
const NoNeedAuth = ['index','auth'];

ModulesFile.keys().reduce((modules, modulePath) => {
    // 路由模块名称   文件夹/index  user/index
    const ModuleName = modulePath.replace(/^.\/(.*)\.js/,'$1');

    if(!NoNeedAuth.includes(ModuleName))
    {
        List.push(...ModulesFile(modulePath).default);
    }

    return List;
},{});

const layout = () =>
{
    return (
        <>
            {/* 显示子级路由 */}
            <React.Router.Outlet />
        </>
    )
}

const RouterList = [
    {
        path:'/product',
        name:'Product',
        component:layout,
        children:List
    }
];

export default RouterList